<template>
	<view class="order-list">
		<view class='list-box' :style="'height:'+( windowHeight)  + 'px'">
			<scroll-view
				:style="currentStatus!=4?'height: '+(windowHeight-80) + 'px;':'height: '+(windowHeight) + 'px;'"
				scroll-y="true" class="scroll-Y">
				<view style=" height: 100%;">
					<view class="list-item">
						<view class="info-transverse">
							<view class="text-7">{{logisticsCompanyName}}</view>
							<view class='copyView'>
								<view class="text-8">{{mailNo}}</view>
								<view class='orderline'></view>
								<view class='copyView'>
									<image class="copyImage" @click='copy(mailNo)' mode='widthFix'
										src='https://pfmotortest.hb4oss.xstore.ctyun.cn/appstatic/img/copy-icon.png' />
								</view>
							</view>
						</view>
						<view class="info-transverse-more" style="margin-top: 16rpx;margin-bottom: 16rpx;">
							<view class="text-7">收货信息</view>
							<view class="info-more-view">
								<view class="text-8">{{consigneeName}} {{consigneePhone}}</view>
								<view class="text-8">{{consigneeAddress}}</view>
							</view>
						</view>
					</view>
					<view class="suggestion-step">
						<block v-for="(item, index) in logisticsTraceDetailList" :key="index" v-if="logisticsTraceDetailList&&logisticsTraceDetailList.length>0">
							<view :class="index==0?'steps active':'steps' ">
								<view class="steps-top">
									<u--image v-if="index==0"
										src="https://dnsverify.pfmoto.com/appstatic/mall/mall_orange_point.png"
										width="10px" height="10px"></u--image>
									<u--image v-else
										src="https://dnsverify.pfmoto.com/appstatic/mall/mall_grey_point.png"
										width="10px" height="10px"></u--image>
								</view>
								<view class="steps-content"
									:style="index==logisticsTraceDetailList.length-1?'border-left: 2px solid #00000000;':''">
									<view style="margin-top: -24px;" :class="index==0?'verticalText1':'verticalText2'">
										<text style="font-weight: 400;margin-right: 12rpx;"
											v-if="item.areaName">({{item.areaName. split(',')[1]}})</text>

										<text v-if="item.desc"> {{item.desc}}</text>
									</view>
									<view class="verticalTexttime" v-if="item.time">{{getTime(item.time)}}
									</view>
								</view>
							</view>
						</block>
					</view>
				</view>

			</scroll-view>

			<view class="cancelBtns" style="background-color: #00000000;">
				<text class="evaluateBtn" @click="confirmReceipt" v-if="currentStatus!=4">确认收货</text>
			</view>
		</view>

	</view>



</template>
<script>
	const app = getApp();
	const util = require('@/utils/util.js');
	const network = require('@/manager/network-manager.js');
	import dayjs from 'dayjs'
	export default {
		data() {
			return {
				windowHeight: app.globalData.windowHeight - app.globalData.navigationBarHeight,
				navigationBarHeight: app.globalData.navigationBarHeight,
				contentHeight: app.globalData.windowHeight - 100,
				logisticsCompanyName: '',
				mailNo: '',
				logisticsTraceDetailList: [],
				consigneePhone: '',
				consigneeName: '',
				consigneeAddress: '',
				freightNo: '',
				orderNo: '',
				currentStatus: '',
				id: ''


			}
		},
		onLoad: function(options) {
			this.consigneePhone = options.consigneePhone
			this.consigneeName = options.consigneeName
			this.consigneeAddress = options.consigneeAddress
			this.freightNo = options.freightNo
			this.orderNo = options.orderNo
			this.currentStatus = options.currentStatus
			this.id = options.confirmReceiptId
			this.getExpressInquiry()

		},


		methods: {
			//获取时间
			getTime: function(time) {
				return dayjs(time).format('YYYY-MM-DD HH:mm:ss')
			},
			//复制单号
			copy: function(orderId) {
				uni.setClipboardData({
					data: orderId
				})
			},
			//快递物流查询
			getExpressInquiry: function() {
				var that = this;
				var uri = app.globalData.config.interfaces
					.URL_SYS_LEVCEXPRESSINQUIRY_GETEXPRESSINQUIRY;
				var params = {
					// 'mobile': '15542570062',
					// 'number': 'SF1828716128127',
					'mobile': that.consigneePhone,
					'number': that.freightNo,
					"orderNo": that.orderNo
				};
				network.post(uri, params, 'json').then(res => {
					if (res.code == 200) {
						that.logisticsCompanyName = res.data[0].logisticsCompanyName
						that.mailNo = res.data[0].mailNo
						that.logisticsTraceDetailList = res.data[0].logisticsTraceDetailList.reverse()
					} else {
						dialog.toast(res.message);
					}
				}).catch(err => {
					console.log(err)
				});
			},
			//确认收货
			confirmReceipt: function() {
				var that = this;
				var uri = app.globalData.config.interfaces
					.URL_PRODUCT_PFMALLORDER_CONFIRMRECEIPT; ///levc-sys/sendMessage/updateLevcMessageUserReady
				var params = {
					"id": this.id
				};
				network.get(uri, params, 'form').then(res => {
					if (res.code == 200) {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})


						uni.navigateBack({
							delta: 1
						});






					} else {
						uni.showToast({
							title: res.message,
							duration: 3000,
							icon: 'none'
						})
					}

				}).catch(res => {
					uni.showToast({
						title: res.errMsg,
						duration: 3000,
						icon: 'none'
					})
					console.error(res);
				});
			},






		}
	}
</script>
<style>
	@import "./mallDetail.css";

	.empty {
		height: 100%;
		width: 100%;

	}

	.empty .img-box {
		width: 388rpx;
		position: relative;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
	}

	.empty .img-box image {
		width: 100%;
	}

	.empty .text {
		text-align: center;
		font-size: 28rpx;
		line-height: 40rpx;
		color: #ADB0AE;
	}

	.u-nav-slot {
		display: flex;
		flex-direction: row;
	}

	/deep/.u-steps-item__wrapper {
		background-color: #f5f5f5;
	}
</style>
